package com.liwenfeng.diancanspringboot.controller.admin;

import com.liwenfeng.diancanspringboot.common.context.BaseContext;
import com.liwenfeng.diancanspringboot.common.result.Result;
import com.liwenfeng.diancanspringboot.pojo.entity.OrderDetail;
import com.liwenfeng.diancanspringboot.service.OrderDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/admin/orderDetail")
public class OrderDetailController {
    @Autowired
    private OrderDetailService orderDetailService;

    //    @GetMapping("/list")
//    public Result<List<OrderDetail>> list() {
//
//        List<OrderDetail> list=orderDetailService.list();
//        return Result.success(list);
//    }
    // 修改订单详情状态（手机端admin模块)
    @PutMapping("/update")
    public Result<String> update(@RequestBody OrderDetail orderDetail) {
        log.info("修改订单详情：{}", orderDetail);
        orderDetailService.update(orderDetail);
        return Result.success();
    }

    // 按工作分配状态，按状态查询订单详情列表（手机端admin模块)
    @GetMapping("/listByStatus")
    public Result<List<OrderDetail>> getOrderDetailByStatus() {
        log.info("查询订单详情：{}", BaseContext.getOther());
        List<OrderDetail> list = orderDetailService.getOrderDetailByStatus();
        return Result.success(list);
    }
}
